package com.srd.phone.utils;

import android.content.Context;

/**
 * 处理文字显示的类
 *
 * @author terry.C
 */

public class TextSizeUtils {

    // dp转换成px
    public static int Dp2Px(Context context, float dp) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dp * scale + 0.5f);
    }

    // px转换成dp
    public static int Px2Dp(Context context, float px) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (px / scale + 0.5f);
    }
}
